package com.bjypc.youth.web;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;

import com.opensymphony.xwork2.ActionSupport;

public class JFreeChartAction extends ActionSupport {
	/**
     * 
     */
    private static final long serialVersionUID = 5752180822913527064L;

    //JChartResult->ActionInvocation.getStack().findValue("chart")
    private JFreeChart chart;
    
    @Override
    public String execute() throws Exception {
        DefaultPieDataset data = new DefaultPieDataset();
        data.setValue("Java", new Double(43.2));
        data.setValue("Visual Basic", new Double(1.0));
        data.setValue("C/C++", new Double(17.5));
        data.setValue("tangjun", new Double(60.0));
        //JFreeChart
        chart = ChartFactory.createPieChart("Pie Chart", data, true,true, false);
        
        return SUCCESS;
    }

    public JFreeChart getChart() {
        return chart;
    }

    public void setChart(JFreeChart chart) {
        this.chart = chart;
    }
}
